 /**
 * 逻辑、功能相关描述: <br>
 *
 * @author 付湘辉  <br>
 * 编写日期：2008-8-14  <br>
 */
package com.ce.pms.charge.dao.impl;

import java.math.BigDecimal;
import java.util.List;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.charge.dao.ICashieringDao;
import com.ce.pms.charge.vo.CashieringSearchVO;
import com.ce.pms.common.annotation.AssociatedBuildingQuery;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.common.util.SqlConfig;
import com.ce.pms.common.util.StringAnalysiUtil;
import com.ce.util.BlankUtil;
import com.sitechasia.webx.core.support.Page;

/**
 * 	名称: com.ce.pms.charge.dao.impl.CashieringDaoImpl <br>
 *
 *
 * @author  付湘辉  <br>
 * Created on： 2008-8-14 <br>
 * @author <br>
 * update on： <br>
 * why: <br>
 */
public class CashieringDaoImpl extends PmsBaseDaoImpl implements ICashieringDao {
	/**
	 * 值： FrontCashier.xml
	 */
	private final String FRONT_SQL_CONFIG_PATH = "FrontCashier.xml";
	/**
	 * 值： queryLatefeeAmtByAccount
	 */
	private final String QUERY_LATEFEEAMT_BY_ACCOUNT="queryLatefeeAmtByAccount";
	/**
	 * 功能描述: 查询指定号码的房间当前相关费用信息 <br>
	 * 注意：返回的page分页对象list数据中是Object[] <br>
	 * [0]：房屋id <br>
	 * [1]：房屋号码<br>
	 * [2]：是否是管理房<br>
     * [3]：业主姓名（有多个用逗号连接）<br>
	 * [4]：业主联系电话（有多个用逗号连接）<br>
	 * [5]：记帐策略<br>
	 * [6]：收费账户余额<br>
	 * [7]：预交款帐户余额<br>
	 * [8]：保证金/押金余额<br>
	 * [9]：滞纳金余额<br>
	 * [10]：是否发生过产权变更标志<br>
	 * [11]：产权id<br>
	 * [12]：帐户id<br>
	 * [13]：产权变更日期<br>
	 * @param searchVo
	 * @return Page
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public Page getEffectiveHouseChargeInfo(CashieringSearchVO searchVO){
	    if (BlankUtil.isBlank(searchVO)) {
			return null;
		}

	    return this.getHouseChargeInfo(searchVO, false);
	}

	/**
	 * 功能描述: 查询指定号码的房间最近一次历史帐户信息 <br>
	 * 注意：返回的page分页对象list数据中是Object[] <br>
	 * [0]：房屋id <br>
	 * [1]：房屋号码<br>
	 * [2]：是否是管理房<br>
     * [3]：业主姓名（有多个用逗号连接）<br>
	 * [4]：业主联系电话（有多个用逗号连接）<br>
	 * [5]：记帐策略<br>
	 * [6]：收费账户余额<br>
	 * [7]：预交款帐户余额<br>
	 * [8]：保证金/押金余额<br>
	 * [9]：滞纳金余额<br>
	 * [10]：是否发生过产权变更标志<br>
	 * [11]：产权id<br>
	 * [12]：帐户id<br>
	 * [13]：产权变更日期<br>
	 * @param searchVo
	 * @return Page
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public Page getLastHouseChargeInfo(CashieringSearchVO searchVO){
	    if (BlankUtil.isBlank(searchVO)) {
			return null;
		}
	    searchVO.setHistory(true);
	    searchVO.setLast(true);

		return this.queryChargeInfoByPage(searchVO);
	}

	/**
	 * 功能描述: 查询指定房屋产权帐户的详细信息 <br>
	 * 注意：返回的数据是Object[] <br>
	 * [0]：房屋id <br>
	 * [1]：房屋号码<br>
	 * [2]：是否是管理房<br>
     * [3]：业主姓名（有多个用逗号连接）<br>
	 * [4]：业主联系电话（有多个用逗号连接）<br>
	 * [5]：记帐策略<br>
	 * [6]：收费账户余额<br>
	 * [7]：预交款帐户余额<br>
	 * [8]：保证金/押金余额<br>
	 * [9]：滞纳金余额<br>
	 * [10]：是否发生过产权变更标志<br>
	 * [11]：产权id<br>
	 * [12]：帐户id<br>
	 * [13]：产权变更日期<br>
	 * [14]：是否是历史产权帐户<br>
	 * [15]：划款银行帐号信息<br>
	 * @param searchVO
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */

	public Object[] queryHouseChargeDetailInfo(CashieringSearchVO searchVO){
		if (BlankUtil.isBlank(searchVO)) {
			return null;
		}
	    searchVO.setDetail(true);

	    StringBuffer fatherQuery = this.generationAccountSQL(searchVO);
		fatherQuery.append(this.fromJoinTable());
		fatherQuery.append(this.generationWhereCondition(searchVO));

		Query query = super.createSQLQuery(fatherQuery.toString());
		List list = query.list();
		if (BlankUtil.isBlank(list)) {
			return null;
		}

	    return (Object[])list.get(0);
	}

	/**
	 * 功能描述: 查询房间历史帐户分页信息 <br>
	 * [0]：房屋id <br>
	 * [1]：房屋号码<br>
	 * [2]：是否是管理房<br>
     * [3]：业主姓名（有多个用逗号连接）<br>
	 * [4]：业主联系电话（有多个用逗号连接）<br>
	 * [5]：记帐策略<br>
	 * [6]：收费账户余额<br>
	 * [7]：预交款帐户余额<br>
	 * [8]：保证金/押金余额<br>
	 * [9]：滞纳金余额<br>
	 * [10]：是否发生过产权变更标志<br>
	 * [11]：产权id<br>
	 * [12]：帐户id<br>
	 * [13]：产权变更日期<br>
	 * @param searchVo
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public Page queryHouseChargeHistoryListByPage(CashieringSearchVO searchVo){
		if (BlankUtil.isBlank(searchVo)) {
			return null;
		}
		searchVo.setHistory(true);
		return this.queryChargeInfoByPage(searchVo);
	}

	/**
	 * 功能描述: 根据总账户id查询收费子账户的滞纳金金额，
	 * 只查询未缴状态的，并且计算调整和减免。 <br>
	 * @param accountId
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-11-10  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public BigDecimal queryLatefeeByAccountId(Long accountId){
		SqlConfig sqlCon = new SqlConfig(this.FRONT_SQL_CONFIG_PATH);
		String sql = sqlCon.getSql(this.QUERY_LATEFEEAMT_BY_ACCOUNT);
		Query query = super.createSQLQuery(sql, new Object[]{accountId,accountId});
		Object obj = query.uniqueResult();
		return obj==null?BigDecimal.ZERO:(BigDecimal)query.uniqueResult();
	}

	/**
	 * 功能描述: 查询帐户的from 和 join table 选项 <br>
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String fromJoinTable(){
		StringBuffer sb = new StringBuffer("FROM ");
		sb.append("HM_HOUSE HH ");
		sb.append("JOIN HM_PRO_RIGHT HPR ON HH.HOUSE_ID=HPR.HOUSE_ID ");
		sb.append("JOIN FEE_ACCOUNT FA ON HPR.PRO_RIGHT_ID=FA.PRO_RIGHT_ID ");
		return sb.toString();
	}

	/** 功能描述: 生成SQL查询语句 <br>
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-21  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	*/
	private StringBuffer generationAccountSQL(CashieringSearchVO searchVO) {
		StringBuffer fatherQuery = new StringBuffer("SELECT ");
		final String ownerName = "PARTICIPANT_NAME";
		final String ownerTel = "TELEPHONE";
		final String ownerNameA = "PARTICIPANTNAME";

		//	房屋id
		fatherQuery.append("HH.HOUSE_ID HOUSEID,");
		//	房屋号码
		fatherQuery.append("HH.HOUSE_NUMBER HOUSENUMBER,");
		//	是否是管理房
		fatherQuery.append("HH.IS_VIRTUAL ISVIRTUAL,");
		//	业主姓名
		fatherQuery.append(this.selectOnwerField(ownerName, ownerNameA));
		//	业主联系电话
		fatherQuery.append(this.selectOnwerField(ownerTel, ownerTel));
		// 记帐策略
		fatherQuery.append("HPR.CHARGE_SELECT CHARGESELECT,");
		// 收费账户余额
		fatherQuery.append(this.selectBalance(SysrefcodeDO.FEE_SUB_ACCOUNT_ACCOUNT_TYPE_CHARGE, "BALANCE"));
		// 预交款帐户余额
		fatherQuery.append(this.selectBalance(SysrefcodeDO.FEE_SUB_ACCOUNT_ACCOUNT_TYPE_PREPAY,"PREPAYBALANCE"));
		// 保证金/押金帐户余额
		fatherQuery.append(this.selectBalance(SysrefcodeDO.FEE_SUB_ACCOUNT_ACCOUNT_TYPE_DEPOSIT,"DEPOSIT"));
		//	滞纳金 (原语句，查所有滞纳金)
//		fatherQuery.append("(SELECT SUM(FT.DEBIT) FROM FEE_TRANSACTION FT,FEE_SUB_ACCOUNT FSA1 ")
//				   .append("WHERE FT.SUB_ACCOUNT_ID=FSA1.SUB_ACCOUNT_ID AND FSA1.ACCOUNT_ID=FA.ACCOUNT_ID AND FT.STATUZ='001' AND FT.CLAZZ_CODE='004') LATEFEE,");
		// 滞纳金 (修改后语句，查所有未缴的滞纳金，同时计算了调整和减免)
		fatherQuery.append(this.generationLatefeeSQL("LATEFEE"));

		//	产权变更标志(原语句)
//		fatherQuery.append("(CASE WHEN ")
//		.append("(SELECT COUNT(DISTINCT FAC.ACCOUNT_ID) FROM FEE_ACCOUNT FAC ")
//		.append("WHERE FAC.HOUSE_ID = HH.HOUSE_ID AND FAC.IS_ACTIVE = 0)>0 THEN '1' ")
//		.append("ELSE '0' END) ISCHANGEPRORIGHT,");

		//	产权变更标志
		// (现语句 2008-10-31
	    //   修改人：付湘辉
		//   原因：合并记账时，原产权房产权并未置无效，但账户已禁用，
		//         原SQL语句无法判断产权变更)
		fatherQuery.append("(CASE WHEN ")
			.append("(SELECT COUNT(DISTINCT FAC.ACCOUNT_ID) FROM FEE_ACCOUNT FAC ")
			.append("JOIN HM_PRO_RIGHT HPR2 ON FAC.PRO_RIGHT_ID=HPR2.PRO_RIGHT_ID ")
			.append("WHERE FAC.HOUSE_ID=HH.HOUSE_ID AND FAC.IS_ACTIVE=0 AND HPR2.VALIDITY=0)>0 THEN '1' ")
			.append("ELSE '0' END) ISCHANGEPRORIGHT,");

		//产权id
		fatherQuery.append("HPR.PRO_RIGHT_ID PRORIGHTID,");
		//总帐户id
		fatherQuery.append("FA.ACCOUNT_ID ACCOUNTID,");
		//产权变更日期
		fatherQuery.append("HPR.MODIFY_DATE PRORIGHTCHANGEDATE ");
		//查询详细信息时需加的字段
		if (searchVO.isDetail()) {
			// 是否不是历史记录
			fatherQuery.append(",HPR.VALIDITY ISNOTHISTORY,");
			//是否有效账户
			//fatherQuery.append(",FA.IS_ACTIVE ISACTIVEACCOUNT,");

			//划款银行帐号信息id,开户人,帐号 CONCAT_WS(',',FBA.BANK_ACCOUNT_ID,FBA.ACC_OWNER,FBA.ACC_NUMBER)
			fatherQuery.append("(SELECT CONCAT_WS(',',CAST(FBA.BANK_ACCOUNT_ID AS CHAR),FBA.ACC_NUMBER,FBA.ACC_OWNER) ")
						.append("FROM FEE_BANK_ACCOUNT FBA ")
						.append("WHERE FBA.PRO_RIGHT_ID=HPR.PRO_RIGHT_ID AND ")
						.append("FBA.IS_ACTIVE=1) BANKACCOUNTINFO ");
		}

		return fatherQuery;
	}

	/**
	 * 功能描述: 查询滞纳金金额(未缴状态的，并且加调整和减免总额) <br>
	 * @param alias
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-11-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String generationLatefeeSQL(String alias){
    	StringBuffer sb = new StringBuffer("(SELECT SUM(FT.DEBIT)");
		sb.append(" FROM FEE_TRANSACTION FT")
			.append(" JOIN FEE_SUB_ACCOUNT FSA1 ON FT.SUB_ACCOUNT_ID=FSA1.SUB_ACCOUNT_ID")
			.append(" WHERE FSA1.ACCOUNT_ID=FA.ACCOUNT_ID AND FT.STATUZ='001' AND")
			.append(" (FT.CLAZZ_CODE='004' OR ((FT.CLAZZ_CODE='002' OR FT.CLAZZ_CODE='003') AND")
			.append(" FT.TRANSACTION_ID IN (")
			.append(" SELECT FTRT.TRANSACTION_ID2 FROM FEE_TRA_R_TRA FTRT")
			.append(" JOIN FEE_TRANSACTION FTR1 ON FTRT.TRANSACTION_ID1=FTR1.TRANSACTION_ID")
			.append(" JOIN FEE_SUB_ACCOUNT FSA2 ON FTR1.SUB_ACCOUNT_ID=FSA2.SUB_ACCOUNT_ID")
			.append(" WHERE FSA2.ACCOUNT_ID=FA.ACCOUNT_ID AND")
			.append(" FTR1.CLAZZ_CODE='004' AND")
			.append(" (FTRT.RELATION_TYPE='001' OR FTRT.RELATION_TYPE='002'))))) ")
			.append(alias).append(",");;
		return sb.toString();
	}

	/** 功能描述: 加入查询条件，对于有效的管理房，
	 * 将查它的所有产权房，对于产权房如果其与其它产权房已合并，
	 * 则会查询相关产权房，如果是合并房记帐，则查询管理房 <br>
	 * @param searchVO
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-21  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	*/
	private String generationWhereCondition(CashieringSearchVO searchVO) {
		StringBuffer whereConditions = new StringBuffer(" WHERE ");

		Long houseId = searchVO.getHouseId();
		String houseCondition = "";
		String houseNumber = StringAnalysiUtil.toTropicalString(searchVO.getHouseNumber(),"'");
		// 如果是查询详细记录
		if (searchVO.isDetail()) {
			whereConditions.append("HPR.PRO_RIGHT_ID=")
						.append(searchVO.getProRightId())
						.append(" AND FA.ACCOUNT_ID=")
						.append(searchVO.getAccountId()+" ");
			houseCondition="HOUSE_ID="+houseId;
			// 如果是查询最近一条记录
		} else if (searchVO.isLast()) {
			whereConditions.append("HPR.VALIDITY=0 ");
			houseCondition="HOUSE_NUMBER='"+houseNumber+"'";
			//只是查询所有历史记录
		}else if (searchVO.getIsHistory()) {
			whereConditions.append("HPR.VALIDITY=0 ");
			houseCondition="HOUSE_ID="+houseId;
			//查询有效帐户记录
		}else{
			whereConditions.append("HPR.VALIDITY=1 ");
			houseCondition="HOUSE_NUMBER='"+houseNumber+"'";
		}

		if (!searchVO.isDetail()) {
			whereConditions.append("AND (HH.IS_VIRTUAL=0 AND HPR.CHARGE_SELECT=1 OR HH.IS_VIRTUAL=1 AND HPR.CHARGE_SELECT=0) ");
		}

		whereConditions.append("AND (");
		//如果不是查历史或不是查详细信息
		if (!(searchVO.getIsHistory()
				|| searchVO.isDetail())) {
			whereConditions.append("HH.HOUSE_ID IN (")
						   .append(this.selectHouseIds(houseCondition,true))
						   .append(" UNION ALL ")
						   .append("SELECT HRRV1.REAL_HOUSE_ID ")
						   .append("FROM HM_REAL_R_VIRTUAL HRRV1 ")
						   .append("JOIN HM_HOUSE HH1 ON HH1.HOUSE_ID = HRRV1.REAL_HOUSE_ID ")
						   .append("WHERE 3=3 AND HRRV1.VIRTUAL_HOUSE_ID IN (")
						   .append(this.selectHouseIds(houseCondition,false))
						   .append(")) OR ");
		}

	    whereConditions.append("(HH.").append(houseCondition+" AND 2=2 ))");
		return whereConditions.toString();
	}

	/**
	 * 功能描述:  <br>
	 * @param searchVO
	 * @param isHistory
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-21  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Page getHouseChargeInfo(CashieringSearchVO searchVO,boolean isHistory){
		searchVO.setHistory(isHistory);
	    return this.queryChargeInfoByPage(searchVO);
	}

	/**
	 * 功能描述: 查询指定号码的房间相关费用分页信息 <br>
	 * 注意：返回的是Object[] <br>
	 * [0]：房屋id <br>
	 * [1]：房屋号码<br>
	 * [2]：是否是管理房<br>
     * [3]：业主姓名（有多个用逗号连接）<br>
	 * [4]：业主联系电话（有多个用逗号连接）<br>
	 * [5]：记帐策略<br>
	 * [6]：收费账户余额<br>
	 * [7]：预交款帐户余额<br>
	 * [8]：保证金/押金余额<br>
	 * [9]：滞纳金余额<br>
	 * [10]：是否发生过产权变更标志<br>
	 * [11]：产权id<br>
	 * [12]：帐户id<br>
	 * [13]：产权变更日期<br>
	 * @param searchVo
	 * @return Page
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	@AssociatedBuildingQuery(alias="HH1",secondAlias="HH", beginStr=" AND ", endStr=" ", insertAfterPoint="WHERE 3=3", secondInsertAfterPoint="AND 2=2", property4Building="BUILDING_ID",isFront=true)
	private Page queryChargeInfoByPage(CashieringSearchVO searchVO){
		if (BlankUtil.isBlank(searchVO)) {
			return null;
		}

		StringBuffer fatherQuery = this.generationAccountSQL(searchVO);
		fatherQuery.append(this.fromJoinTable());
		fatherQuery.append(this.generationWhereCondition(searchVO));
		if (searchVO.isLast()) {
			fatherQuery.append(" GROUP BY HH.HOUSE_ID ");
		}
		if (searchVO.getIsHistory()) {
			fatherQuery.append(" ORDER BY HPR.MODIFY_DATE DESC ");
		}

		Page page = super.pagedSqlQueryByPageNo(fatherQuery.toString(), searchVO.getPageNo(), searchVO.getPageSize());

		return page;
	}

	/**
	 * 功能描述: 查询不同类型帐户余额 <br>
	 * @param accountType 帐户类型
	 * @param alias 别名
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String selectBalance(String accountType,String alias){
		StringBuffer sb = new StringBuffer("(SELECT ");
		sb.append("BALANCE FROM FEE_SUB_ACCOUNT FSA1 ")
			.append("WHERE ACCOUNT_TYPE='").append(accountType).append("'")
			.append(" AND FSA1.ACCOUNT_ID=FA.ACCOUNT_ID) ")
			.append(alias).append(",");
		return sb.toString();
	}
	/**
	 * 功能描述: 选择出符合条件的房屋id,包括管理房的 <br>
	 * @param houseCondition
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-26  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String selectHouseIds(String houseCondition,boolean isDacl){
		StringBuffer sb = new StringBuffer("SELECT DISTINCT HRRV.VIRTUAL_HOUSE_ID ");
		sb.append("FROM HM_HOUSE HH1,HM_MANAGE HMA,HM_REAL_R_VIRTUAL HRRV ")
		.append("WHERE");
		 if(isDacl){
			 sb.append(" 3=3 AND ");
		 }
		 sb.append(" ((HH1.HOUSE_ID=HRRV.VIRTUAL_HOUSE_ID OR ")
		.append("HH1.HOUSE_ID=HRRV.REAL_HOUSE_ID) AND ")
		.append("HMA.MANAGE_ID=HRRV.VIRTUAL_HOUSE_ID) AND ")
		.append("HMA.VALIDITY=1 AND ")
		.append("HH1.").append(houseCondition);
		return sb.toString();
	}

	/**
	 * 功能描述: 查询业主表某个字段并用逗号连接成一个字符串 <br>
	 * @param fieldNmae 表字段名
	 * @param alias 别名
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private String selectOnwerField(String fieldNmae,String alias){
		StringBuffer sb = new StringBuffer("(SELECT ");
		sb.append("GROUP_CONCAT(DISTINCT CP.").append(fieldNmae).append(") ")
			.append("FROM CS_CLIENT_R_HOUSE CCRH ")
			.append("JOIN CS_CLIENT CC ON CCRH.PARTICIPANT_ROLE_ID=CC.CLIENT_ID ")
			.append("JOIN CS_PARTICIPANT_ROLE CPR ON CC.CLIENT_ID=CPR.PARTICIPANT_ROLE_ID ")
			.append("JOIN CS_PARTICIPANT CP ON CP.PARTICIPANT_ID=CPR.PARTICIPANT_ID ")
			.append("JOIN SYS_REF_CODE SRCS ON SRCS.SYS_REF_ID=CC.SYS_REF_ID AND ")
			.append("SRCS.SYS_REF_CODE='CS_CLIENT_CLIENT_TYPE' AND SRCS.SYS_REF_VALUE='001' ");

		sb.append("WHERE CCRH.PRO_RIGHT_ID=HPR.PRO_RIGHT_ID AND ")
			.append("(CCRH.HOUSE_ID IN (")
			.append("SELECT HRRV1.REAL_HOUSE_ID FROM HM_REAL_R_VIRTUAL HRRV1 ")
			.append("WHERE HRRV1.VIRTUAL_HOUSE_ID=HH.HOUSE_ID) OR ")
			.append("CCRH.HOUSE_ID=HH.HOUSE_ID ) GROUP BY HH.HOUSE_ID) ")
			.append(alias).append(",");
		return sb.toString();
	}

}
